Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-Contract #40

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

sophia1ch
Copy link

This PR introduces cross-contract payment channels. This is implemented by adding a backends field to the allocation, changing the channelID to an array of channelIDs and changing the participant struct to include addresses from other blockchains.

iljabvh and others added 6 commits August 7, 2024 14:34
…dhat

Signed-off-by: Ilja von Hoessle <ilja@perun.network>
Signed-off-by: Ilja von Hoessle <ilja@perun.network>
…ment Channels

Signed-off-by: Ilja von Hoessle <ilja@perun.network>
Signed-off-by: Sophia Koehler <sophia@perun.network>
Signed-off-by: Sophia Koehler <sophia@perun.network>
feat(adjudicator, assetholder): optimize gas usage
feat: remove safemath usage, over- and underflows are checked automatically since solidity 0.8.0
fix(test): remove pubkey from participant

Signed-off-by: Sophia Koehler <sophia@perun.network>

- name: Install dependencies
run: yarn

- name: Lint
run: npx solhint 'contracts/**/*.sol'

- name: Build
run: yarn build
- name: Install Hardhat and other dependencies
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need these dependencies, why not add them to the dev dependencies? Unusual to install selected dependencies in workflow script.

@matthiasgeihs
Copy link
Contributor

This PR introduces cross-contract payment channels. This is implemented by adding a backends field to the allocation, changing the channelID to an array of channelIDs and changing the participant struct to include addresses from other blockchains.

How do you maintain security of such a cross-contract channel? Don’t you need virtual channels for that? Do you have a more detailed spec for that feature?

@sophia1ch
Copy link
Author

This PR introduces cross-contract payment channels. This is implemented by adding a backends field to the allocation, changing the channelID to an array of channelIDs and changing the participant struct to include addresses from other blockchains.

How do you maintain security of such a cross-contract channel? Don’t you need virtual channels for that? Do you have a more detailed spec for that feature?

We still rely on payment channels, but in go-perun, we allow multiple backends to be imported so that different implementations of the adjudicator and funder can be used within a single channel.

To ensure security, we continue using the same encoding and signature methods across all backends. This ensures that a signature generated by one backend (e.g., the Stellar backend) can be verified on another backend and contract, such as Ethereum, and vice versa.

@matthiasgeihs
Copy link
Contributor

@sophia1ch got it, i think that makes sense. thank you for outlining the approach! cheers!

Signed-off-by: Sophia Koehler <sophia@perun.network>
Signed-off-by: Sophia Koehler <sophia@perun.network>
Signed-off-by: Sophia Koehler <sophia@perun.network>
Signed-off-by: Sophia Koehler <sophia@perun.network>
Signed-off-by: Sophia Koehler <sophia@perun.network>
Signed-off-by: Sophia Koehler <sophia@perun.network>
@sophia1ch sophia1ch mentioned this pull request Jan 14, 2025
address app;
bool ledgerChannel;
bool virtualChannel;
}

struct Participant {
address ethAddress;
bytes ccAddress;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is ccAddress?

Copy link

@iljabvh iljabvh Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the L1 address for any other non-EVM chain, encoded in bytes. Currently, we support cross-chain Ethereum-to-non-EVM Payment Channels for the Stellar network (see our Stellar Contract and Backend Repositories).

But in principle we can implement channels between Ethereum and any chain that lets us emulate Solidity encoding within their respective contract (again, see our Stellar WASM contract). For Rust, there are proper crates to do this, so any L1 chain with Rust-based Smart Contracts is supported to have secure channels to Ethereum-based chains.

Yes, it is that awesome.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so you are allowing your participant identifiers to be multi-chain, right? wouldn't it have been cleaner to just use one abstract bytes field then? what if you have more than two chains?

more concretely, what looks odd to me here is that this is not symmetric anymore. like you are treating the eth network as a special case, while all other networks would go under ccAddress.

@sophia1ch sophia1ch marked this pull request as ready for review January 14, 2025 10:52
@iljabvh iljabvh self-requested a review January 15, 2025 07:32
* feat(.sol): Change channelID array to singular channelID and remove unnecessary functions

Signed-off-by: Sophia Koehler <sophia@perun.network>

* fix(Assetholder): Remove immutable flag
fix(ci.yaml): Add immutable-state to slither exclusion

Signed-off-by: Sophia Koehler <sophia@perun.network>

---------

Signed-off-by: Sophia Koehler <sophia@perun.network>
Signed-off-by: Sophia Koehler <sophia@perun.network>
Signed-off-by: Sophia Koehler <sophia@perun.network>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants